home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / COMPHELP / BATCHTUT.LZH / _QUERY.REM < prev    next >
Text File  |  1983-08-25  |  3KB  |  92 lines

  1.                            Text File      _query.rem
  2.  
  3.  
  4.  
  5.                                 QUERY.COM
  6.  
  7. The purpose of the QUERY utility is to allow the user of a Batch File to answer
  8. a prompting message or comment with a yes/no (or ESC) response.  The QUERY
  9. utility then sets the system "errorlevel" parameter so that a subsequent IF
  10. subcommand in the Batch File can branch accordingly.  QUERY will optionally
  11. execute some display formatting commands before it displays a prompt string.
  12.  
  13.  
  14. The format of the QUERY command line is shown below, with the usual convention
  15. that items in brackets  [ ]  are optional.
  16.  
  17.         QUERY    [ /  [ c1 [ c2 ... ] ]  / ]   [ string ]
  18.  
  19.  
  20. where   c1, c2, etc are optional formatting commands enclosed in slashes.
  21. These commands are executed in the order they are encountered, before the
  22. string is displayed.  The one-letter commands that are currently supported
  23. include the following:
  24.  
  25.  
  26.         B  or  b        Beep the console
  27.  
  28.         L  or  l        Skip one line
  29.  
  30.         D  or  d        Display a "delimiting" border across the screen.
  31.  
  32.  
  33. After the "slash" commands are executed, the string is displayed.  If no
  34. slashes precede the string, the leading blanks and tabs are discarded.  If
  35. slashes were present, then all characters after the second slash are
  36. displayed.
  37.  
  38. The only constraint on the string's characters is that "<", "|", and ">" must
  39. not be used in the string.
  40.  
  41. Following the string, a reverse video "box" is displayed.  When the user
  42. responds with a keystroke, the box "un-reverses" and the character is
  43. displayed.
  44.  
  45. QUERY then returns to the Batch File with the errorlevel parameter set as
  46. follows:
  47.  
  48.  
  49.  
  50.  
  51.                 errorlevel = 2          if user typed Esc key
  52.  
  53.                 errorlevel = 1          if user typed Y or y
  54.  
  55.                 errorlevel = 0          if user typed N or n
  56.  
  57. If any other key is typed, the console is beeped, a message is displayed, and
  58. QUERY waits for another keystroke.
  59.  
  60. Let's return to the Batch File to show some examples.  The first example shows
  61. the simplest use of QUERY and how to test the errorlevel code with subsequent
  62. IF subcommands.  We'll first display the command lines in these comments, and
  63. then we will return to the Batch File and execute the same command lines.
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. Here are the command lines:
  76.  
  77.         query   Is this example easy (y/n) ?
  78.         if errorlevel 2 goto esc_key
  79.         if not errorlevel 1 goto n_key
  80.         echo    You typed a "Y" or a "y"
  81.         goto continue
  82.         :n_key
  83.         echo    You typed a "N" or an "n"
  84.         goto continue
  85.         :esc_key
  86.         echo    you pressed the Esc key
  87.         :continue
  88.  
  89. Examine the command lines (remember that the logic of the "IF" test is "greater
  90. than or equal to" and the "IF NOT" test, "less than" ), then strike a key and
  91. we'll execute the sequence.
  92.